//
//  MainNavigationController.m
//  基本框架
//
//  Created by runone02 on 2018/6/26.
//  Copyright © 2018年 liqiyun. All rights reserved.
//

#import "BaseNavigationController.h"

@interface BaseNavigationController ()
@property (nonatomic, strong) UIView *bottomNavLine;
@end

@implementation BaseNavigationController

- (UIView *)bottomNavLine{
    if (!_bottomNavLine) {
        _bottomNavLine = [[UIView alloc]initWithFrame:CGRectMake(0,44, kScreenSize.width, 1.0/[UIScreen mainScreen].scale)];
        _bottomNavLine.backgroundColor = [ZMColor colorWithHexString:@"0xDCDCDC"];
    }
    return _bottomNavLine;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    //藏旧
    //    [self hideBorderInView:self.navigationBar];
    //    //添新
    //    [self.navigationBar addSubview:self.bottomNavLine];
}


- (void)hideBorderInView:(UIView *)view{
    if ([view isKindOfClass:[UIImageView class]] && view.frame.size.height <= 1) {
        view.hidden = YES;
    }
    for (UIView *subView in view.subviews) {
        [self hideBorderInView:subView];
    }
}

- (void)hideNavBottomLine{
    [self hideBorderInView:self.navigationBar];
    if (_bottomNavLine) {
        _bottomNavLine.hidden = YES;
    }
}

- (void)showNavBottomLine{
    _bottomNavLine.hidden = NO;
}

- (instancetype)initWithRootViewController:(UIViewController *)rootViewController{
    self = [super initWithRootViewController:rootViewController];
    if (self) {
        self.statusBarStyle = UIStatusBarStyleDefault;
    }
    return self;
}

- (UIStatusBarStyle)preferredStatusBarStyle{
    return self.statusBarStyle;
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    if (self.viewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = YES;
    }
    [super pushViewController:viewController animated:animated];
}

@end
